package com.crm.service.statisticAnalysis.controller;

import com.crm.model.common.dtos.ResponseResult;
import com.crm.model.statisticAnalysis.dtos.ChannelPageDTO;
import com.crm.service.statisticAnalysis.service.ChannelService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.format.annotation.DateTimeFormat;
import org.springframework.web.bind.annotation.*;

import java.time.LocalDate;

@RestController
@RequestMapping("/api/v1/statistics/channel")
@Slf4j
@Api(value = "渠道统计")
public class ChannelController {
    @Autowired
    private ChannelService channelService;

    @ApiOperation("渠道统计分页查询")
    @PostMapping("/channelPage")
    private ResponseResult channelPage(@RequestBody ChannelPageDTO channelPageDTO) {
        log.info("渠道统计分页:{}", channelPageDTO);
        return channelService.channelPage(channelPageDTO);
    }

    @ApiOperation("饼状图+环形图")
    @GetMapping("/channel_doughnutChart")
    private ResponseResult doughnutChart(@DateTimeFormat(pattern = "yyyy-MM-dd") LocalDate queryTime){
        log.info("饼状图+环形图,{}",queryTime);
       return channelService.doughnutChart(queryTime);
    }


}
